package parser;

import java.util.List;

import represent.expression.Expression;
import represent.expression.Predicate;
import server.SimpleDB;
import storage.transaction.Transaction;

public class ModifyData extends ManipulateData {

	private String tblname;
	private List<String> fldname;
	private List<Expression> newval;
	private Predicate pred;

	public ModifyData(String tblname, List<String> fldname, List<Expression> newval, Predicate pred) {
		this.tblname = tblname;
		this.fldname = fldname;
		this.newval = newval;
		this.pred = pred;
	}

	public String tableName() {
		return tblname;
	}
	public List<String> targetField() {
		return fldname;
	}
	public List<Expression> newValue() {
		return newval;
	}
	public Predicate pred() {
		return pred;
	}

	@Override
	public int execute(Transaction tx) {
		return SimpleDB.uplanner().executeModify(this, tx);
	}
}
